package com.onest;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.core.io.FileSystemResource;
import org.springframework.jdbc.core.JdbcTemplate;

public class Test {
    @org.junit.Test
    public void testMain(){
        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicationContext.xml");
        UserDao userDao= (UserDao) applicationContext.getBean("userDao");
        userDao.sayHello();
        JdbcTemplate jdbcTemplate= (JdbcTemplate) applicationContext.getBean("jdbcTemplate");
        jdbcTemplate.execute("select * from user");
        System.out.println("success");
    }
   /* public static void main(String[] args) throws Throwable {
//        BeanFactory beanFactory=new XmlBeanFactory(new FileSystemResource("path"));
//        ApplicationContext ac=new FileSystemXmlApplicationContext("path");
          ApplicationContext applicationContext=new ClassPathXmlApplicationContext("applicationContext.xml");
        UserDao userDao= (UserDao) applicationContext.getBean("userDao");
        userDao.sayHello();
        JdbcTemplate jdbcTemplate= (JdbcTemplate) applicationContext.getBean("jdbcTemplate");
        jdbcTemplate.execute("select * from user");
        System.out.println("success");
       *//* System.out.println(applicationContext.getBean("user1"));
        System.out.println(applicationContext.getBean("user2"));*//*
       *//*动态代理*//*
      *//* JdkProxy jdkProxy=new JdkProxy();
       UserDao userDao= (UserDao) jdkProxy.createProxy(new UserDaoImpl());
       userDao.sayHello();
       CglibProxy cglibProxy=new CglibProxy();
       UserDao2 userDao2= (UserDao2) cglibProxy.createProxy(new UserDao2());
        userDao2.addUser();*//*
    }*/
}
